package com.heima.controller;

import com.heima.common.Result;
import com.heima.domain.dto.VendingMachineDto;
import com.heima.service.VendingMachineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service/vm")
@Api(tags = "设备管理")
public class VendingMachineController {

    @Autowired
    private VendingMachineService vendingMachineService;

    @GetMapping("/search")
    @ApiOperation("设备分页搜索")
    public Result getBYPage(@RequestParam(required = false) Integer pageIndex,
                            @RequestParam(required = false) Integer pageSize,
                            @RequestParam(required = false) String innerCode){
        Result result = vendingMachineService.getByPage(pageIndex,pageSize,innerCode);
        return result;
    }

    @PostMapping
    @ApiOperation("新增设备")
    public Boolean addVendingMachine(@RequestBody VendingMachineDto dto){
        Boolean flag = vendingMachineService.addVendingMachine(dto);
        return flag;
    }

}
